<?php

Yii::import('common.models._base.BaseProfiles');

class Profiles extends BaseProfiles {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public $termcondition;

    public function rules() {
        return array(
            array('termcondition,', 'required'),
            array('termcondition', 'compare', 'compareValue' => 1, 'message' => 'You should accept term to use our service'),
            //array('termcondition', 'required', 'requiredValue' => 1, 'message' => 'You should accept term to use our service', 'on' => 'updateprofile'),
            array('user_id, timestamp, phone, age, skill_country_id, skill_state_id', 'numerical', 'integerOnly' => true),
            array('privacy', 'length', 'max' => 9),
            array('first_name,termcondition,phone', 'required', 'on' => 'update'),
            array('date_of_birth', 'length', 'max' => 10),
            array('photo, facebook, twitter, linkedin, website_title, website_link, blog_title, blog_link, others, others_link', 'length', 'max' => 145),
            array('facebook,twitter,linkedin,website_link,blog_link,others_link', 'url', 'defaultScheme' => 'http', 'message' => 'Please use http://'),
            array('other_info', 'length', 'max' => 500),
            array('about, experience', 'safe'),
            array('last_name, first_name, phone, age, date_of_birth, photo, about, experience, other_info, skill_country_id, skill_state_id, facebook, twitter, linkedin, website_title, website_link, blog_title, blog_link, others, others_link', 'default', 'setOnEmpty' => true, 'value' => null),
            array('profile_id, user_id, timestamp, privacy, last_name, first_name, phone, age, date_of_birth, photo, about, experience, other_info, skill_country_id, skill_state_id, facebook, twitter, linkedin, website_title, website_link, blog_title, blog_link, others, others_link, cache_last_updated', 'safe'),
            array('profile_id, user_id, timestamp, privacy, last_name, first_name, phone, age, date_of_birth, photo, about, experience, other_info, skill_country_id, skill_state_id, facebook, twitter, linkedin, website_title, website_link, blog_title, blog_link, others, others_link, cache_last_updated', 'safe', 'on' => 'search'),
        );
    }

    public function relations() {
        return array(
            'corporateprogram' => array(self::HAS_ONE, 'CorporateProgram', 'profiles_id', 'order' => 'corporateprogram.id DESC'),
            'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
            'skillCountry' => array(self::BELONGS_TO, 'Country', 'skill_country_id'),
            'skillState' => array(self::BELONGS_TO, 'State', 'skill_state_id'),
        );
    }

    public function attributeLabels() {
        return array(
            'profile_id' => Yii::t('app', 'Profile'),
            'user_id' => Yii::t('app', 'User'),
            'timestamp' => Yii::t('app', 'Timestamp'),
            'privacy' => Yii::t('app', 'Privacy'),
            'last_name' => Yii::t('app', 'Last Name'),
            'first_name' => Yii::t('app', 'First Name'),
            'phone' => Yii::t('app', 'Phone'),
            'age' => Yii::t('app', 'Experience'),
            'date_of_birth' => Yii::t('app', 'Date Of Birth'),
            'photo' => Yii::t('app', 'Photo'),
            'about' => Yii::t('app', 'About'),
            'experience' => Yii::t('app', 'Experience'),
            'other_info' => Yii::t('app', 'Other Info'),
            'skill_country_id' => Yii::t('app', 'Skill Country'),
            'skill_state_id' => Yii::t('app', 'Skill State'),
            'facebook' => Yii::t('app', 'Facebook'),
            'twitter' => Yii::t('app', 'Twitter'),
            'linkedin' => Yii::t('app', 'Linkedin'),
            'website_title' => Yii::t('app', 'Website Title'),
            'website_link' => Yii::t('app', 'Website Link'),
            'blog_title' => Yii::t('app', 'Blog Title'),
            'blog_link' => Yii::t('app', 'Blog Link'),
            'others' => Yii::t('app', 'Others'),
            'others_link' => Yii::t('app', 'Others Link'),
            'cache_last_updated' => Yii::t('app', 'Cache Last Updated'),
        );
    }

}